import { utf8to16, base64decode} from '../../utils/base64.js'
var WxParse = require('../../wxParse/wxParse.js');
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    pageData: {
      type: Object
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
  },
  attached: function(){
    var self=this;
    var content = utf8to16(base64decode(this.data.pageData.Text));
   
    //替换标签中特殊字符
    var infoFlg = "<!--SPINFO#0-->";
    var imgFlg = "<!--IMG#";
    var content = "<div style=\"margin:10px; line-height:25px; font-weight:200; font-size:17px; color:black; word-break:normal\">" + content + "</div>";

    //替换标签中特殊字符
    var infoFlg = "<!--SPINFO#0-->";
    if (content.indexOf(infoFlg) > 0) {
      content = content.replace(/<!--SPINFO#0-->/, "");
    }

    var imgFlg = "<!--IMG#";
    //图片数量
    var imgCount = (content.split(imgFlg)).length - 1;
    if (imgCount > 0) {
    

      for (var i = 0; i < imgCount; i++) {
        var imgStr = "<!--IMG#" + i + "-->";
        var imgSrc = "\"" + imgInfoArr[i].src + "\"";
        var imgHTML = "<div> <img style=\"width:100%\" src=" + imgSrc + "> </div>";
        content = content.replace(imgStr, imgHTML);
      }
    }
    WxParse.wxParse('article', 'html', content, self, imgCount);
 
   // WxParse.wxParse('article', 'html', content, self, imgCount);
    
  },

  /**
   * 组件的方法列表
   */
  methods: {

  }
})





